package com.cc.wechat.controller;

import com.cc.wechat.common.ApiResponse;
import com.cc.wechat.common.constants.MessageConstants;
import com.cc.wechat.dto.response.UserSearchResponse;
import com.cc.wechat.service.UserService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 用户控制器
 * 处理用户相关的请求，包括用户搜索等
 */
@RestController
@RequestMapping("/api/users")
@RequiredArgsConstructor
public class UserController {

    private final UserService userService;

    /**
     * 搜索用户
     * @param email 通过邮箱搜索用户
     * @return 搜索结果响应
     */
    @GetMapping("/search")
    public ApiResponse<UserSearchResponse> searchUser(@RequestParam String email) {
        return ApiResponse.success(MessageConstants.User.SEARCH_SUCCESS, userService.searchUserByEmail(email));
    }
} 